import request from '@/utils/axios'

export type DictTypeType = {
  id: number | undefined
  name: string
  type: string
  status: number
  remark: string
  createTime: Date
}

export type DictDataType = {
  id: number | undefined
  sort: number | undefined
  label: string
  value: string
  dictType: string
  status: number
  colorType: string
  cssClass: string
  remark: string
  createTime: Date
}

/**
 * 字典接口
 */
export const DictApi = {
  // 字典类型相关接口
  Type: {
    // 新增字典
    create: (data: DictTypeType) => {
      return request.post({ url: '/system/dict-type/create', data, is_mock: true })
    },
    // 修改字典
    update: (data: DictTypeType) => {
      return request.put({ url: '/system/dict-type/update', data, is_mock: true })
    },
    // 删除字典
    delete: (id: number) => {
      return request.delete({ url: '/system/dict-type/delete?id=' + id, is_mock: true })
    },
    // 查询字典详情
    detail: (id: number) => {
      return request.get({ url: '/system/dict-type/get?id=' + id, is_mock: true })
    },
    // 查询字典分页列表
    page: params => {
      return request.get({ url: '/system/dict-type/page', params, is_mock: true })
    },
    // 查询字典列表
    list: () => {
      return request.get({ url: '/system/dict-type/list-all-simple', is_mock: true })
    },
    // 导出字典类型
    export: params => {
      return request.download({ url: '/system/dict-type/export', params, is_mock: true })
    }
  },
  // 字典数据相关接口
  Data: {
    // 新增字典数据
    create: (data: DictDataType) => {
      return request.post({ url: '/system/dict-data/create', data, is_mock: true })
    },
    // 修改字典数据
    update: (data: DictDataType) => {
      return request.put({ url: '/system/dict-data/update', data, is_mock: true })
    },
    // 删除字典数据
    delete: (id: number) => {
      return request.delete({ url: '/system/dict-data/delete?id=' + id, is_mock: true })
    },
    // 查询字典数据详情
    detail: (id: number) => {
      return request.get({ url: '/system/dict-data/get?id=' + id, is_mock: true })
    },
    // 查询字典数据列表
    page: params => {
      return request.get({ url: '/system/dict-data/page', params, is_mock: true })
    },
    // 查询字典数据（精简)列表
    list: () => {
      return request.get({ url: '/system/dict-data/simple-list', is_mock: true })
    },
    // 导出字典类型数据
    export: params => {
      return request.download({ url: '/system/dict-data/export', params, is_mock: true })
    }
  }
}
